<?php

/**
 * DoctorBilling form base class.
 *
 * @method DoctorBilling getObject() Returns the current form's model object
 *
 * @package    docplus.co.za
 * @subpackage form
 * @author     Fox Matuku
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseDoctorBillingForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'doctor_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Doctor'), 'add_empty' => false)),
      'frequency'         => new sfWidgetFormChoice(array('choices' => array('Monthly' => 'Monthly', 'Biannually' => 'Biannually', 'Annually' => 'Annually', 'Never' => 'Never'))),
      'type'              => new sfWidgetFormChoice(array('choices' => array('Direct deposit' => 'Direct deposit', 'EFT' => 'EFT', 'Credit card' => 'Credit card', 'Debit order' => 'Debit order', 'Free' => 'Free'))),
      'amount'            => new sfWidgetFormInputText(),
      'last_billing_date' => new sfWidgetFormDateTime(),
      'next_billing_date' => new sfWidgetFormDateTime(),
      'admin_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Admin'), 'add_empty' => false)),
      'created_at'        => new sfWidgetFormDateTime(),
      'updated_at'        => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'doctor_id'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Doctor'))),
      'frequency'         => new sfValidatorChoice(array('choices' => array(0 => 'Monthly', 1 => 'Biannually', 2 => 'Annually', 3 => 'Never'), 'required' => false)),
      'type'              => new sfValidatorChoice(array('choices' => array(0 => 'Direct deposit', 1 => 'EFT', 2 => 'Credit card', 3 => 'Debit order', 4 => 'Free'), 'required' => false)),
      'amount'            => new sfValidatorNumber(),
      'last_billing_date' => new sfValidatorDateTime(),
      'next_billing_date' => new sfValidatorDateTime(),
      'admin_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Admin'))),
      'created_at'        => new sfValidatorDateTime(),
      'updated_at'        => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('doctor_billing[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'DoctorBilling';
  }

}
